/*******************************************************************************
GDialog.h

	Author:		LiuDingXi
	e-mail:		liudx@gmail.com
	Date time:	2009-08-07

	Copyright (C) 2009
	All rights reserved.
	
*******************************************************************************/

#ifndef _GDIALOG_H_
#define _GDIALOG_H_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "GEngine.h"
#include "GScene.h"
#include "GControl.h"

class GDialog : public GControl
{
public:
	GDialog();
	virtual ~GDialog();

	BOOL Create(GScene* pScene, UINT nID);
	BOOL Destroy();

	void OnDraw(GDC* pDC);
	bool IsVisible()const;

	void Update(UINT nMillisecond);

	BOOL DoModal(int x, int y);

	PMRV ProcMsg(GMsg& refMsg);
	
	BOOL GetBox(BOX& refBox)const;
	BOOL GetCxy(CXY& refCxy)const;

	BOOL IsValid()const;

	GControl*	GetItem(SINT i)const;
	
protected:
	GScene*		m_pScene;
	struct PITEM
	{
		BOOL		bDestroy;
		GControl*	pControl;
	};
	PITEM*	m_ppItems;
	
	GDialog*	m_pNext;	// only used by GSight GScene

	friend class GSight;
	friend class GScene;

	virtual BOOL DataBind(GSight* pSight, const BYTE* pBase, SceneDat::PTR ptr);
	
	virtual BOOL InitItem(GSight* pSight, GControl* pCtrl, UINT nID, BOOL bDestroy = FALSE);

	virtual BOOL OnInitDialog(GSight* pSight);

	virtual BOOL OnCommand(UINT nCtrlId, UINT nCommand);

	virtual void EndDialog();

	BOOL		m_bModal;
};



#endif//_GDIALOG_H_
